package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;


@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "MiniAppType", description = "小程序类型")
public enum MiniAppType implements BaseEnum {

    WX("微信小程序"),
    ALIPAY("支付宝小程序"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static MiniAppType match(String val, MiniAppType def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static MiniAppType get(String val) {
        return match(val, null);
    }

    public boolean eq(MiniAppType val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "WX,ALIPAY", example = "WX")
    public String getCode() {
        return this.name();
    }

}
